#!/bin/bash

set -o errexit

export LC_ALL=C

COMPARE_TYPE=$1
BASE_ANN_DIR=$2

for GA_DIR in ${BASE_ANN_DIR}/annot_*; do

    GENE_ID=`head -n1 $GA_DIR/gene.faa | cut -b 2-`

    echo -ne ${GENE_ID}'\t'$(basename $GA_DIR)

    for PW in `cat $GA_DIR/../genes_pathways.txt | grep ${GENE_ID} | cut -f2`; do
   
        RES=`cat $BASE_ANN_DIR/pathways_go.txt | grep $PW | cut -f2 \
            | 9_annotation_analysis/get_pathways_coverage_full.py "${COMPARE_TYPE}" $GA_DIR/e_5/results_gene_ontology.txt.gz`

        echo -ne '\t'$RES
    done

    echo

done > ${BASE_ANN_DIR}/results_pw_coverage_full_${COMPARE_TYPE}.txt


